require('./Girdview.styl');
import urllist from 'clientConfig/urllist';
import net from 'clientConfig/util/net';
import { Control } from 'react-keeper';
const { Grid } = SaltUI;
const monStorage = require('clientConfig/util/StoreData').monStorage;
const Storage = require('clientConfig/util/StoreData').Storage;
const ui = require('clientConfig/util/jsapi/ui');
/**
 * title:格子的标题
 * path:url跳转
 * src:图片的路径
 */
const Girdview = ({ girdItems, path }) => {
    if (!girdItems) return;
    let variableString = [];
    for (let key in girdItems) {
        const svgs = {
            workplan: {
                workplan0: {
                    svg1: require("images/svg/module/workplan/planApproval/pending.svg"),
                    svg2: require("images/svg/module/workplan/planApproval/sponsored.svg"),
                    svg3: require("images/svg/module/workplan/planApproval/copy.svg"),
                    svg4: require("images/svg/module/workplan/planApproval/changereq.svg"),
                    svg5: require("images/svg/module/workplan/planApproval/changerecord.svg")
                },
                workplan1: {
                    svg1: require("images/svg/module/workplan/tracking/project_overview.svg"),
                    svg2: require("images/svg/module/workplan/tracking/project_single.svg"),
                    svg3: require("images/svg/module/workplan/tracking/pay_statistics.svg"),
                }
            },
            achievements: {
                achievements1: {
                    svg1: require("images/svg/module/achievements/process.svg"),
                    svg2: require("images/svg/module/achievements/qulity.svg"),
                    svg3: require("images/svg/module/achievements/version.svg"),
                }
            },
            maintenance: {
                maintenance1: {
                    svg1: require("images/svg/module/maintenance/maintaintable.svg"),
                }
            },
            schedule: {
                schedule0: {
                    svg1: require("images/svg/module/schedule/tenderprocess.svg"),
                    svg2: require("images/svg/module/schedule/projprocess.svg"),
                    svg3: require("images/svg/module/schedule/payprocess.svg"),
                    svg4: require("images/svg/module/schedule/miantainprogress.svg"),
                }
            }
        };
        let path1 = girdItems[key].homesvg.split("_")[0];
        if (path1 == "workplan0" || path1 == "workplan1") {
            path = "workplan";
        } 
        let path2 = girdItems[key].homesvg.split("_")[1];
        variableString.push(svgs[path][path1][path2]);
    }
    let [AgencydocSvg, NewfileSvg, DealeddocSvg, NoticedocSvg, ServiceinfoSvg, ReconciliationSvg, AddresslistSvg, EmailSvg, MeetingroomSvg] = variableString;
    //九宫格页面跳转
    let handleLink = (options, title) => {
        ui.setTitle({ title });
        // /home/achievements/pending => /home/workplan/pending,workplan
        let field = options.split("/")[3];  
        let param = options.split("/")[2]+"/"+options.split("/")[3];
         if(field=="pending"||field=="sponsored"||field=="copy"||field=="changereq"||field=="changerecord"||field=="progresstrack"||field=="singleproject" ){
            options = "/home/workplan/"+options.split("/")[3] 
         }        
        //url的#跳转
        Control.go(options,{origin:param,origin_title:title})
 
    }
    return (
        <div className="girdview">
            <Grid className="ft14 t-PL15 t-PR15" col={window.innerWidth >= 1000 ? 5 : 3} square={true} touchable={false} noLine={true}>
                {girdItems && girdItems.map((item, index) => {
                    return (<div className="t-FAC" onClick={() => { handleLink(item.hashPath, item.title) }} data-id={index}>
                        <div style={{ position: 'relative' }}>
                            {index == 0 && <AgencydocSvg  />}
                            {index == 1 && <NewfileSvg  />}
                            {index == 2 && <DealeddocSvg  />}
                            {index == 3 && <NoticedocSvg  />}
                            {index == 4 && <ServiceinfoSvg  />}
                            {index == 5 && <ReconciliationSvg  />}
                            {index == 6 && <AddresslistSvg  />}
                            {index == 7 && <EmailSvg  />}
                            {index == 8 && <MeetingroomSvg  />}
                        </div>
                        <div className=" t-SMT12 gird-item">{girdItems[index].title}</div>
                    </div>);
                })}
            </Grid>
        </div>);
}
module.exports = Girdview;
